<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    *{
        margin: 0;
        padding: 0;
    }
    .container{
        width: 200px;
        height: 200px;
        margin: 100px auto;
        perspective: 500px;
    }

    .box{
        width: 200px;
        height: 200px;
        transform-style: preserve-3d;
        position: relative;
        transition: all 1s;
    }
    .box:hover{
        transform: rotate3d(1,1,0,45deg);
    }
    .box div{
        width: 200px;
        height: 200px;
        border: 1px solid black;
        position: absolute;
        opacity: 0.5;
    }
    .front{
        transform: translateZ(100px);
        background-color: #08f;
    }
    .back{
        transform: translateZ(-100px);
        background-color: olive;
    }
    .top{
        transform: rotateX(90deg)  translateZ(100px);
        background-color: cyan;
    }
    .bottom{
        transform: rotateX(-90deg) translateZ(100px);
        background-color: #FF9966;
    }
    .left{
        transform: rotateY(90deg) translateZ(100px);
        background-color: pink;
    }
    .right{
        transform: rotateY(-90deg)  translateZ(100px);
        background-color: orange;
    }
</style>
<body>
    <div class="container">
        <div class="box">
            <div class="front">前</div>
            <div class="back">后</div>
            <div class="top">上</div>
            <div class="bottom">下</div>
            <div class="left">左</div>
            <div class="right">右</div>
        </div>
    </div>
</body>
</html>